import sys
import time

from PySide6 import QtWidgets,QtCore,QtGui


class MyQLabel(QtWidgets.QLabel):
    def __init__(self):
        super(MyQLabel, self).__init__()
    # 重写Qlabel的mousePressEvent方法,参数e表示事件源即label对象,button()表示被触发的是点击事件
    def mousePressEvent(self, e):
        if(e.button()==QtCore.Qt.LeftButton):
            # MainUI().right_widget.hide()
            # MainUI().right_widget2.show()
            # print(MainUI().right_widget2.isHidden())
            # print(MainUI().right_widget.isHidden())
            # # 点击完成以后   widget2隐藏   widegt显示

            MainUI().right_widget2.show()
            MainUI().right_widget.hide()
            MainUI().right_widget3.hide()
            print("已经设置好了")
            print(MainUI().right_widget2.isHidden())
            print(MainUI().right_widget.isHidden())
            # 点击完成以后      widegt显示  widget2隐藏


class MainUI(QtWidgets.QMainWindow):
    __instance = None
    __flag=False
    def __new__(cls, *args, **kwargs):
        if cls.__instance is None:
            cls.__instance=super().__new__(cls)
        return cls.__instance
    def __init__(self):
        print(1)
        if not MainUI.__flag:
            MainUI.__flag=True
            super().__init__()
            self.init_Mainui()
    def init_Mainui(self):
        self.setWindowTitle("Paper Tool")
        self.main_widget=QtWidgets.QWidget()  # 创建窗口主部件
        self.main_layout=QtWidgets.QGridLayout()  # 创建主部件的网格布局
        self.main_widget.setLayout(self.main_layout)  #设置窗口主部件布局为网格布局


        self.left_widget=QtWidgets.QWidget() # 创建左侧部件
        self.left_widget.setObjectName('left_widget')
        self.left_widget.setMinimumSize(190,650)
        self.left_layout=QtWidgets.QGridLayout() # 创建左侧部件的网格布局层
        self.left_widget.setLayout(self.left_layout) # 设置左侧部件布局为网格
        self.scroll=QtWidgets.QScrollArea() # 左侧部件的上一级为滚动条
        self.scroll.setWidget(self.left_widget)
        self.scroll.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) # 将滚动区域自带的垂直滚动条隐藏





        self.right_widget = QtWidgets.QWidget()  # 创建右侧1号部件  展示首页
        self.right_widget.setObjectName('right_widget')
        self.right_layout = QtWidgets.QGridLayout()  # 创建右侧部件的网格布局层
        self.right_widget.setLayout(self.right_layout)  # 设置右侧部件布局为网格


        self.right_widget2 = QtWidgets.QWidget()  # 创建右侧2号部件   展示搜索结果页面
        self.right_widget2.setObjectName('right_widget')
        self.right_layout2 = QtWidgets.QGridLayout()  # 创建右侧部件的网格布局层
        self.right_widget2.setLayout(self.right_layout2)  # 设置右侧部件布局为网格

        self.right_widget3 = QtWidgets.QWidget()  # 创建右侧3号部件   展示阅读界面
        self.right_widget3.setObjectName('right_widget')
        self.right_layout3 = QtWidgets.QGridLayout()  # 创建右侧部件的网格布局层
        self.right_widget3.setLayout(self.right_layout3)  # 设置右侧部件布局为网格
        self.ql=QtWidgets.QLabel("这是文章内容")
        self.right_layout3.addWidget(self.ql)

        # 创建空对象:需要空对象来传递属性,防止self这一个类下的的属性重命名
        t1= type('test', (object,), {})()
        t2 = type('test', (object,), {})()
        t3 = type('test', (object,), {})()
        self.right_layout2.addWidget(self.right_bookwidget(t1).right_widget2_book_widget,0,0,3,9)
        self.right_layout2.addWidget(self.right_bookwidget(t2).right_widget2_book_widget,4,0,3,9)
        self.right_layout2.addWidget(self.right_bookwidget(t3).right_widget2_book_widget,8,0,3,9)
        self.right_widget.show()
        self.right_widget2.hide()
        self.right_widget3.hide()

        ## 开始设计right_widget2界面


        self.main_layout.addWidget(self.scroll,0,0,12,1)
        self.main_layout.addWidget(self.right_widget,0,1,12,10)
        self.main_layout.addWidget(self.right_widget2,0,1,12,10)
        self.main_layout.addWidget(self.right_widget3,0,1,12,10)

        self.setCentralWidget(self.main_widget)
        self.main_layout.setSpacing(0)
        self.init_LeftUI()
        self.init_rightUI()
        self.scroll.setStyleSheet('''    
                QLabel{
                    color:#72727b;
                    font-size:14px;
                }        
        ''')
    def init_LeftUI(self):

        # 创建图标
        self.left_icon=QtWidgets.QToolButton(self.left_widget)
        self.left_icon.setText("纸条")
        self.left_icon.setIcon(QtGui.QPixmap('./icon.png'))
        self.left_icon.setIconSize(QtCore.QSize(60,60))
        self.left_icon.setToolButtonStyle(QtCore.Qt.ToolButtonTextBesideIcon)
        self.left_icon.setFixedSize(100,100)
        self.left_icon.move(50,0)


        # move()默认单位为px,凡是涉及长宽或位移的单位,统一是px
        self.left_label1=QtWidgets.QLabel("书籍",self.left_widget)
        self.left_label1.move(50,100)
        # 书籍标签下面的按钮
        # left_button1  网文
        # left_button2  小说
        # left_button3  论文
        # left_button4  其他书籍

        self.left_button1 = QtWidgets.QPushButton(self.left_widget)
        self.left_button1.setObjectName('left_button')
        self.left_button1.setFont(self.font(11))
        self.left_button1.setText(chr(0xf2da)+'网文')
        self.left_button1.move(50,130)

        self.left_button2 = QtWidgets.QPushButton(self.left_widget)
        self.left_button2.setObjectName('left_button')
        self.left_button2.setFont(self.font(11))
        self.left_button2.setText(chr(0xf097) + '小说')
        self.left_button2.move(50,160)


        self.left_button3 = QtWidgets.QPushButton(self.left_widget)
        self.left_button3.setObjectName('left_button')
        self.left_button3.setFont(self.font(11))
        self.left_button3.setText(chr(0xf02d) + '论文')
        self.left_button3.move(50,190)


        self.left_button4 = QtWidgets.QPushButton(self.left_widget)
        self.left_button4.setObjectName('left_button')
        self.left_button4.setFont(self.font(11))
        self.left_button4.setText(chr(0xf02d) + '其他书籍')
        self.left_button4.move(50,220)

        self.left_label2=QtWidgets.QLabel("拓展",self.left_widget)
        self.left_label2.move(50,270)
        # 拓展标签下面的按钮
        # left_button1  题库
        # left_button2  书友圈(public)
        # left_button3  书友交流(群和交流)


        self.left_button5 = QtWidgets.QPushButton(self.left_widget)
        self.left_button5.setObjectName('left_button')
        self.left_button5.setFont(self.font(11))
        self.left_button5.setText(chr(0xf2da)+'题库')
        self.left_button5.move(50,300)

        self.left_button6 = QtWidgets.QPushButton(self.left_widget)
        self.left_button6.setObjectName('left_button')
        self.left_button6.setFont(self.font(11))
        self.left_button6.setText(chr(0xf097) + '圈子')
        self.left_button6.move(50,330)

        self.left_button7 = QtWidgets.QPushButton(self.left_widget)
        self.left_button7.setObjectName('left_button')
        self.left_button7.setFont(self.font(11))
        self.left_button7.setText(chr(0xf02d) + '交流')
        self.left_button7.move(50,360)

        self.left_label3=QtWidgets.QLabel("创作",self.left_widget)
        self.left_label3.move(50,410)
        # 拓展标签下面的按钮  创作模块下还有提交功能
        # left_button1  题库
        # left_button2  书籍


        self.left_button8 = QtWidgets.QPushButton(self.left_widget)
        self.left_button8.setObjectName('left_button')
        self.left_button8.setFont(self.font(11))
        self.left_button8.setText(chr(0xf2da)+'题库')
        self.left_button8.move(50,440)

        self.left_button9 = QtWidgets.QPushButton(self.left_widget)
        self.left_button9.setObjectName('left_button')
        self.left_button9.setFont(self.font(11))
        self.left_button9.setText(chr(0xf097) + '书籍')
        self.left_button9.move(50,470)

        self.left_label4=QtWidgets.QLabel("我的",self.left_widget)
        self.left_label4.move(50,520)
        # 创建的收藏
        # 本地和下载
        # 阅读历史

        self.left_button10 = QtWidgets.QPushButton(self.left_widget)
        self.left_button10.setObjectName('left_button')
        self.left_button10.setFont(self.font(11))
        self.left_button10.setText(chr(0xf2da)+'收藏')
        self.left_button10.move(50,550)

        self.left_button11 = QtWidgets.QPushButton(self.left_widget)
        self.left_button11.setObjectName('left_button')
        self.left_button11.setFont(self.font(11))
        self.left_button11.setText(chr(0xf097) + '本地下载')
        self.left_button11.move(50,580)

        self.left_button12 = QtWidgets.QPushButton(self.left_widget)
        self.left_button12.setObjectName('left_button')
        self.left_button12.setFont(self.font(11))
        self.left_button12.setText(chr(0xf097) + '阅读历史')
        self.left_button12.move(50,610)
        self.left_widget.setStyleSheet(
            '''
                QPushButton{
                    border:none;color:#40404c;
                    text-align:left;
                }
                QPushButton#left_button:hover{border-left:4px solid red;font-weight:700;}
                QWidget#left_widget{
                    background:#f5f5f5;
                    border-top:1px solid white;
                    border-bottom:1px solid white;
                    border-left:1px solid white;
                    border-top-left-radius:10px;
                    border-bottom-left-radius:10px;
                }
                QToolButton{
                    border:none;color:white;
                    background: transparent;
                }
            '''
        )

    def init_rightUI(self):
        # 搜索框布局
        self.right_bar_widget=QtWidgets.QWidget()  # 右侧顶部搜索框部件
        self.right_bar_layout=QtWidgets.QGridLayout() # 右侧顶部搜索框网格布局
        self.right_bar_widget.setLayout(self.right_bar_layout)
        self.right_bar_widget_serchInput=QtWidgets.QLineEdit()
        self.right_bar_widget_serchInput.setPlaceholderText("输入论文名称")
        self.serch_icon=MyQLabel()
        self.serch_icon.setFont(self.font(12))
        self.serch_icon.setText(chr(0xf002)+'搜索')
        self.right_bar_layout.addWidget(self.serch_icon,0,0,1,1)
        self.right_bar_layout.addWidget(self.right_bar_widget_serchInput,0,1,1,8)
        # 如何处理位置显示不全的问题
        self.right_layout.addWidget(self.right_bar_widget,0,0,1,9)

        # 书籍推荐
        self.right_recommmend_label=QtWidgets.QLabel('今日推荐')
        self.right_recommmend_label.setObjectName('right_label')

        self.right_recommmend_widget=QtWidgets.QWidget()  # 推荐封面部件
        self.right_recommmend_layout=QtWidgets.QGridLayout() # 推荐封面网格布局
        self.right_recommmend_widget.setLayout(self.right_recommmend_layout)

        self.right_recommmend_button1=QtWidgets.QToolButton()
        self.right_recommmend_button1.setText("PRML")  # 设置按钮文本
        self.right_recommmend_button1.setIcon(QtGui.QIcon('./Image/Image/1.jpg')) # 设置按钮图标
        self.right_recommmend_button1.setIconSize(QtCore.QSize(100,100))  # 设置图标大小
        self.right_recommmend_button1.setToolButtonStyle(QtCore.Qt.ToolButtonTextUnderIcon) # 设置按钮形式为上图下文

        self.right_recommmend_button2 = QtWidgets.QToolButton()
        self.right_recommmend_button2.setText("ML凸优化")  # 设置按钮文本
        self.right_recommmend_button2.setIcon(QtGui.QIcon('./Image/Image/2.jpg'))  # 设置按钮图标
        self.right_recommmend_button2.setIconSize(QtCore.QSize(100, 100))  # 设置图标大小
        self.right_recommmend_button2.setToolButtonStyle(QtCore.Qt.ToolButtonTextUnderIcon)  # 设置按钮形式为上图下文

        self.right_recommmend_button3 = QtWidgets.QToolButton()
        self.right_recommmend_button3.setText("图解机器学习")  # 设置按钮文本
        self.right_recommmend_button3.setIcon(QtGui.QIcon('./Image/Image/3.jpg'))  # 设置按钮图标
        self.right_recommmend_button3.setIconSize(QtCore.QSize(100, 100))  # 设置图标大小
        self.right_recommmend_button3.setToolButtonStyle(QtCore.Qt.ToolButtonTextUnderIcon)  # 设置按钮形式为上图下文

        self.right_recommmend_button4 = QtWidgets.QToolButton()
        self.right_recommmend_button4.setText("编译器设计")  # 设置按钮文本
        self.right_recommmend_button4.setIcon(QtGui.QIcon('./Image/Image/4.jpg'))  # 设置按钮图标
        self.right_recommmend_button4.setIconSize(QtCore.QSize(100, 100))  # 设置图标大小
        self.right_recommmend_button4.setToolButtonStyle(QtCore.Qt.ToolButtonTextUnderIcon)  # 设置按钮形式为上图下文

        self.right_recommmend_button5 = QtWidgets.QToolButton()
        self.right_recommmend_button5.setText("算法分析导论")  # 设置按钮文本
        self.right_recommmend_button5.setIcon(QtGui.QIcon('./Image/Image/5.jpg'))  # 设置按钮图标
        self.right_recommmend_button5.setIconSize(QtCore.QSize(100, 100))  # 设置图标大小
        self.right_recommmend_button5.setToolButtonStyle(QtCore.Qt.ToolButtonTextUnderIcon)  # 设置按钮形式为上图下文

        self.right_recommmend_layout.addWidget(self.right_recommmend_button1,0,1)
        self.right_recommmend_layout.addWidget(self.right_recommmend_button2,0,2)
        self.right_recommmend_layout.addWidget(self.right_recommmend_button3,0,3)
        self.right_recommmend_layout.addWidget(self.right_recommmend_button4,0,4)
        self.right_recommmend_layout.addWidget(self.right_recommmend_button5,0,5)

        self.right_layout.addWidget(self.right_recommmend_label,1,0,1,9)
        self.right_layout.addWidget(self.right_recommmend_widget,2,0,2,9)

        # 最新书籍
        self.right_newbook_label=QtWidgets.QLabel("最新书籍")
        self.right_newbook_label.setObjectName('right_label')

        self.right_popbook_label=QtWidgets.QLabel("热门书籍")
        self.right_popbook_label.setObjectName('right_label')

        self.right_newbook_widget=QtWidgets.QWidget()   # 最新书籍部件
        self.right_newbook_layout=QtWidgets.QGridLayout()  # 最新书籍部件网格布局
        self.right_newbook_widget.setLayout(self.right_newbook_layout)

        self.newbook_button1=QtWidgets.QPushButton("编程珠玑2      塞昂斯      编程      179/300")
        self.newbook_button2=QtWidgets.QPushButton("编程珠玑2      塞昂斯      编程      179/300")
        self.newbook_button3=QtWidgets.QPushButton("编程珠玑2      塞昂斯      编程      179/300")
        self.newbook_button4=QtWidgets.QPushButton("编程珠玑2      塞昂斯      编程      179/300")
        self.newbook_button5=QtWidgets.QPushButton("编程珠玑2      塞昂斯      编程      179/300")
        self.newbook_button6=QtWidgets.QPushButton("编程珠玑2      塞昂斯      编程      179/300")

        self.right_newbook_layout.addWidget(self.newbook_button1,0,1)
        self.right_newbook_layout.addWidget(self.newbook_button2,1,1)
        self.right_newbook_layout.addWidget(self.newbook_button3,2,1)
        self.right_newbook_layout.addWidget(self.newbook_button4,3,1)
        self.right_newbook_layout.addWidget(self.newbook_button5,4,1)
        self.right_newbook_layout.addWidget(self.newbook_button6,5,1)
        # 热门书籍
        self.right_popbook_widget=QtWidgets.QWidget()  # 热门书籍部件
        self.right_popbook_layout=QtWidgets.QGridLayout() # 热门书籍网格布局
        self.right_popbook_widget.setLayout(self.right_popbook_layout)

        self.popbook_button1 = QtWidgets.QToolButton()
        self.popbook_button1.setText("黑客与画家")  # 设置按钮文本
        self.popbook_button1.setIcon(QtGui.QIcon('./Image/Image/4.jpg'))  # 设置按钮图标
        self.popbook_button1.setIconSize(QtCore.QSize(100, 100))  # 设置图标大小
        self.popbook_button1.setToolButtonStyle(QtCore.Qt.ToolButtonTextUnderIcon)  # 设置按钮形式为上图下文

        self.popbook_button2 = QtWidgets.QToolButton()
        self.popbook_button2.setText("算法")  # 设置按钮文本
        self.popbook_button2.setIcon(QtGui.QIcon('./Image/Image/4.jpg'))  # 设置按钮图标
        self.popbook_button2.setIconSize(QtCore.QSize(100, 100))  # 设置图标大小
        self.popbook_button2.setToolButtonStyle(QtCore.Qt.ToolButtonTextUnderIcon)  # 设置按钮形式为上图下文

        self.popbook_button3 = QtWidgets.QToolButton()
        self.popbook_button3.setText("设计模式之禅")  # 设置按钮文本
        self.popbook_button3.setIcon(QtGui.QIcon('./Image/Image/4.jpg'))  # 设置按钮图标
        self.popbook_button3.setIconSize(QtCore.QSize(100, 100))  # 设置图标大小
        self.popbook_button3.setToolButtonStyle(QtCore.Qt.ToolButtonTextUnderIcon)  # 设置按钮形式为上图下文

        self.popbook_button4 = QtWidgets.QToolButton()
        self.popbook_button4.setText("clean code")  # 设置按钮文本
        self.popbook_button4.setIcon(QtGui.QIcon('./Image/Image/4.jpg'))  # 设置按钮图标
        self.popbook_button4.setIconSize(QtCore.QSize(100, 100))  # 设置图标大小
        self.popbook_button4.setToolButtonStyle(QtCore.Qt.ToolButtonTextUnderIcon)  # 设置按钮形式为上图下文

        self.right_popbook_layout.addWidget(self.popbook_button1,0,0)
        self.right_popbook_layout.addWidget(self.popbook_button2,0,1)
        self.right_popbook_layout.addWidget(self.popbook_button3,1,0)
        self.right_popbook_layout.addWidget(self.popbook_button4,1,1)

        self.right_layout.addWidget(self.right_newbook_label,4,0,1,5)
        self.right_layout.addWidget(self.right_popbook_label,4,5,1,4)
        self.right_layout.addWidget(self.right_newbook_widget,5,0,1,5)
        self.right_layout.addWidget(self.right_popbook_widget,5,5,1,4)
        self.right_bar_widget_serchInput.setStyleSheet(
            '''QLineEdit{
                    border:1px solid gray;
                    width:300px;
                    border-radius:10px;
                    padding:2px 4px;
            }'''
        )
        self.right_widget.setStyleSheet(
            '''
                QWidget#right_widget{
                    color:#232C51;
                    background:white;
                    border-top:1px solid darkGray;
                    border-bottom:1px solid darkGray;
                    border-right:1px solid darkGray;
                    border-top-right-radius:10px;
                    border-bottom-right-radius:10px;
                }
                QLabel#right_label{
                    border:none;
                    font-size:16px;
                    font-weight:700;
                    font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
                }
            '''
        )
        self.right_recommmend_widget.setStyleSheet(
            '''
                    QToolButton{border:none;}
                    QToolButton:hover{border-bottom:2px solid #F76677;}
            '''
        )
        self.right_popbook_widget.setStyleSheet(
            '''
                    QToolButton{border:none;}
                    QToolButton:hover{border-bottom:2px solid #F76677;}
            '''
        )
        self.right_newbook_widget.setStyleSheet(
            '''
                QPushButton{
                    border:none;
                    color:gray;
                    font-size:12px;
                    height:40px;
                    padding-left:5px;
                    padding-right:10px;
                    text-align:left;
                }
                QPushButton:hover{
                    color:black;
                    border:1px solid #F3F3F5;
                    border-radius:10px;
                    background:LightGray;
                }
            '''
        )
    # 搜索结果中的书籍组件
    def right_bookwidget(self,name):
        print(name)
        name.right_widget2_book_widget = QtWidgets.QWidget()  # 书籍部件
        name.right_widget2_book_layout = QtWidgets.QGridLayout()  # 书籍部件网格布局
        name.right_widget2_book_widget.setLayout(name.right_widget2_book_layout)

        # 组件初始化
        name.bookimage = QtWidgets.QPushButton()
        name.bookimage.setObjectName("bookimage")
        name.bookimage.setSizePolicy(QtWidgets.QSizePolicy.Ignored,QtWidgets.QSizePolicy.Ignored)
        name.bookname = QtWidgets.QPushButton("间间")
        name.bookname.setObjectName("bookname")
        name.wordsnumber = QtWidgets.QLabel("4791总字数")
        name.author = QtWidgets.QPushButton("sweet熙熙   浪漫青春   连载")
        name.introduce = QtWidgets.QLabel("来阅文旗下网站阅读我更多的作品吧")
        name.introduce.setObjectName("introduce")
        name.introduce.setWordWrap(True)
        name.detail = QtWidgets.QPushButton("最新更新   第四章   绝对不可能的事情好吧")
        name.updatetime = QtWidgets.QLabel("2021-07-18")
        name.read = QtWidgets.QPushButton("开始阅读")
        name.read.setSizePolicy(QtWidgets.QSizePolicy.Ignored,QtWidgets.QSizePolicy.Ignored)
        name.like = QtWidgets.QPushButton("加入收藏")
        name.like.setSizePolicy(QtWidgets.QSizePolicy.Ignored,QtWidgets.QSizePolicy.Ignored)

        # 组件美观化
        name.bookimage.setStyleSheet('''
            QPushButton#bookimage{
                background-image: url(./Image/Image/book.jpg);
                background-size: contain;
                border:none;
            }
        ''')
        name.bookname.setStyleSheet('''
            QPushButton#bookname{
                margin-left:20px;
                padding-left:0px;
                font-size:20px;
                border:none;
            }
        ''')
        name.introduce.setStyleSheet('''
            QLabel{
                margin-left:20px;
                padding-left:0px;
                color:#666;
                font-size:14px;
                border:none;
            }
        ''')
        name.detail.setStyleSheet('''
            QPushButton{
                margin-left:20px;
                padding-left:0px;
                color: #3f5a93;
                font-size:12px;
                border:none;
            }
        ''')
        name.updatetime.setStyleSheet('''
            QPushButton{
                color: #3f5a93;
                font-size:12px;
                border:none;
            }
        ''')
        name.author.setStyleSheet('''
            QPushButton{
                margin-left:20px;
                padding-left:0px;
                color: #b5b5b5;
                font-size:12px;
                border:none;
            }
        ''')
        name.read.setStyleSheet('''
            QPushButton{
                color: #fff;
                border-color: #bf2c24;
                background: #bf2c24;
                font-size:14px;
                border:none;
            }
        ''')
        name.like.setStyleSheet('''
            QPushButton{
                color: #3f5a93;
                border:1px solid #3f5a93;
                font-size:14px;
            }
        ''')
        # 组件布局
        name.right_widget2_book_layout.addWidget(name.bookimage, 0, 0, 6, 1)
        name.right_widget2_book_layout.addWidget(name.wordsnumber, 0, 7, 2, 1,QtCore.Qt.AlignRight)
        name.right_widget2_book_layout.addWidget(name.bookname, 0, 2, 2, 1,QtCore.Qt.AlignLeft)
        name.right_widget2_book_layout.addWidget(name.author, 2, 2, 1, 2,QtCore.Qt.AlignLeft)
        name.right_widget2_book_layout.addWidget(name.introduce, 3, 2, 2, 3,QtCore.Qt.AlignTop)
        name.right_widget2_book_layout.addWidget(name.detail, 5, 2, 1, 3,QtCore.Qt.AlignLeft)
        name.right_widget2_book_layout.addWidget(name.updatetime, 5, 5, 1, 1,QtCore.Qt.AlignLeft)
        name.right_widget2_book_layout.addWidget(name.read, 4, 6, 2, 1)
        name.right_widget2_book_layout.addWidget(name.like, 4, 7, 2, 1)
        name.bookimage.clicked.connect(self.show_RightWidget3)
        return name
    def font(self,size):
        # 加载字体图标  awesome-font v4
        fontId = QtGui.QFontDatabase.addApplicationFont("fontawesome-webfont.ttf")
        fontName = QtGui.QFontDatabase.applicationFontFamilies(fontId)
        font = QtGui.QFont(fontName, size)
        return font
    def show_RightWidget3(self):
        print("出现了")
        self.right_widget.hide()
        self.right_widget2.hide()
        self.right_widget3.show()

def main():
    app=QtWidgets.QApplication(sys.argv)
    gui=MainUI()
    gui.show()
    app.setWindowIcon(QtGui.QIcon("icon.ico"))
    sys.exit(app.exec())

if __name__=='__main__':
    main()